<#macro uploadImg name="" value="" width="78" height="78">
	<#assign idName=name?replace(".","") /> <!-- 兼容复杂页面中类似产品中 name='info.image'的情况 -->
	<div class="action-pic-upload clearfix">
	    <div id="filePicker_${idName}" class="filePicker_btn">
	        <div id="filePicker_${idName}_pre" data-id="${idName}" class="filePicker_view">
	            <#if value?? && value!="">
	                <div class="uploadImg">
	                    <img src="${Uploader.getUrl(value)}" width="${width}" height="${height}" />
	                    <div class="uploadImg-opr">
	                        <a href="javascript:;"  onclick="upload_${idName}.delFile(this)">删除</a>
	                    </div>
	                </div>
	            <#else> 
	                <img src="/style/admin/img/moren.png" id="filePicker_${idName}_detailImg" width="${width}" height="${height}" alt="" />
	            </#if>
	        </div>
	        <input type="hidden" id="input_${idName!}" value="${value!}" name="${name!}" />
	    </div>
	    <div style="width: ${width}px; text-align: center;">
	    	<div id="filePicker_${idName}_btn" class="uploader-add-btn">添加图片</div>
	    </div>
	</div>
	<script type="text/javascript">
	    $(document).ready(function(){
	    	upload_${idName} = new $WebUpload(imgAccept,
		        "${idName}", ${width}, ${height},
		        "", 
		        false,
		        "",
		        "${name}", 
		        function(response) {}
		    );
	    	
	    	upload_${idName}.init();
	    });
	</script>
</#macro>

<#macro uploadImgs files=[] width="78" height="78">
	<#assign name=files[0][0]?replace(".","") /> <!-- 兼容复杂页面中类似产品中 name='info.image'的情况 -->
	<#assign valName="" />
	<#list files as file>
	    <#assign valName=valName + "," + file[0] />
	</#list>
	<#assign valName=valName?substring(1) />
	<#assign hasImg=false />
	<#assign size=files?size />
	<div class="action-pic-upload clearfix">
	    <div id="filePicker_${name}" class="filePicker_btn">
	        <div id="filePicker_${name}_pre" data-id="${name}" class="filePicker_view">
	            <#list files as file><#if file[1]?? && file[1]!=''>
	                <#assign hasImg=true />
	                <div class="uploadImg">
	                    <img src="${Uploader.getUrl(file[1])}" width="${width}" height="${height}" />
	                    <div class="uploadImg-opr">
	                        <a href="javascript:;" onclick="upload_${name}.delFile(this)">删除</a>
	                    </div>
	                    <input type="hidden" id="input_${file[0]}" value="${file[1]}" name="${file[0]}" />
	                </div>
	            </#if></#list>
	            <#if !hasImg>
	                <img src="/style/admin/img/moren.png" id="filePicker_${name}_detailImg" width="${width}" height="${height}" alt="" /> 
	            </#if>
	        </div>
	    </div>
	    <div id="filePicker_${name}_btn" class="uploader-add-btn">添加图片</div>
	</div>
	<script type="text/javascript">
	    $(document).ready(function(){
	        upload_${name} = new $WebUpload(imgAccept, 
	            "${name}", ${width}, ${height}, 
	            "", 
	            true,
	            ${size},
	            "${valName}", 
	            function(response) {}
	        );
	        upload_${name}.init();
	    });
	</script>
</#macro>

<#macro uploadExcel>
	<div class="filePicker_btn clearfix">
	    <div id="filePicker_excel_pre" class="filePicker_view"></div>
	</div>
	<div id="filePicker_excel_btn" class="uploader-add-btn" style="margin-bottom: 10px;">上传文件Excel</div> 
	<input type="hidden" name="fileId" id="fileId" /> 
	<input type="hidden" name="fileName" id="fileName" /> 
	<input type="hidden" name="fileUrl" id="fileUrl" /> 
	<script type="text/javascript">
	    $(document).ready(function(){
	    	upload_excel = new $WebUpload(excelAccept, 
	    		"excel", 
	    		100, 
	    		75, 
	    		"", 
	    		false,
	    		'',
	    		'',
	    		function(response) {
	                $("#fileId").val(response.data.fileId);
	                $("#fileName").val(response.data.fileName);
	                $("#fileUrl").val(response.data.fileUrl);
	        	}	
	    	);
	    	upload_excel.init();
	    });
	</script>
</#macro>

<#macro uploadFile name="" fileId="" fileName="">
	<#assign idName=name?replace(".","") />
	<div class="filePicker_btn clearfix">
	    <div id="filePicker_${idName}_pre" class="filePicker_view">
	    	<#if fileName?? && fileName != ''>
	    		<span id="filePicker_${idName}_file" class="file-url">${fileName}</span>
	    	</#if>
	    </div>
	</div>
	<div id="filePicker_${idName}_btn" class="uploader-add-btn" style="margin-bottom: 10px;">上传文件</div> 
	<#if fileName?? && fileName != ''>
	<div id="filePicker_${idName}_down_btn" class="uploader-add-btn" style="margin-bottom: 10px; padding-left: 15px; padding-right: 15px;">下载文件</div>
	<div id="filePicker_${idName}_preview_btn" class="uploader-add-btn" style="margin-bottom: 10px; padding-left: 15px; padding-right: 15px;">预览文件</div>
	<div id="filePicker_${idName}_del_btn" class="uploader-add-btn" style="margin-bottom: 10px; padding-left: 15px; padding-right: 15px;">删除文件</div>
	<#else>
	<div id="filePicker_${idName}_down_btn" class="uploader-add-btn hidden" style="margin-bottom: 10px; padding-left: 15px; padding-right: 15px;">下载文件</div>
	<div id="filePicker_${idName}_preview_btn" class="uploader-add-btn hidden" style="margin-bottom: 10px; padding-left: 15px; padding-right: 15px;">预览文件</div>
	<div id="filePicker_${idName}_del_btn" class="uploader-add-btn hidden" style="margin-bottom: 10px; padding-left: 15px; padding-right: 15px;">删除文件</div>
	</#if>
	<input type="hidden" name="${name}" id="${idName}_fileId" value="${fileId}" /> 
	<input type="hidden" name="${name}Name" id="${idName}_fileName" value="${fileName}" /> 
	<input type="hidden" name="${name}Url" id="${idName}_fileUrl" value="${Uploader.getUrl(fileId!)}"/> 
	<script type="text/javascript">
	    $(document).ready(function(){
	    	upload_${idName} = new $WebUpload(fileAccept, 
	    		"${idName}", 
	    		100, 
	    		75, 
	    		"", 
	    		false,
	    		'',
	    		'',
	    		function(response) {
	    			console.log(response);
	                $("#${idName}_fileId").val(response.data.fileId);
	                $("#${idName}_fileName").val(response.data.fileName);
	                $("#${idName}_fileUrl").val(response.data.fileUrl);
                    
                    $("#filePicker_${name}_down_btn").removeClass("hidden");
                    $("#filePicker_${name}_preview_btn").removeClass("hidden");
                    $("#filePicker_${name}_del_btn").removeClass("hidden");
	        	}	
	    	);
	    	upload_${idName}.init();
	    	
	    	$("#filePicker_${idName}_down_btn").click(function(){
	    		file.download($("#${idName}_fileId").val(), $("#${idName}_fileName").val());
	    	});
	    	$("#filePicker_${idName}_preview_btn").click(function(){
	    		file.preview($("#${idName}_fileUrl").val(),$("#${idName}_fileName").val());
	    	});
	    	$("#filePicker_${idName}_del_btn").click(function(){
	    		$("#${idName}_fileId").val("");
                $("#${idName}_fileName").val("");
                $("#${idName}_fileUrl").val("");
	    		$("#filePicker_${idName}_pre").html("");
	    		
	    		$("#filePicker_${name}_down_btn").addClass("hidden");
                $("#filePicker_${name}_preview_btn").addClass("hidden");
                $("#filePicker_${name}_del_btn").addClass("hidden");
	    	});
	    });
	</script>
</#macro>

<#macro uploadFiles name="" value="" size=5 >
	<#assign idName=name?replace(".","") />
	<div class="filePicker_btn clearfix">
	    <div id="filePicker_${idName}_pre" class="filePicker_view">
	    </div>
	</div>
	
	<input type="hidden" name="${name}" id="${idName}_value" value="${value}" />
	<div id="filePicker_${idName}_btn" class="uploader-add-btn" style="margin-bottom: 10px;">上传文件</div> 
	<script type="text/javascript">
		var ${idName}_fileShow = function(id, fileId, fileName, fileUrl) {
	    	var $li = '<div class="file-box" data-id="'+id+'">' +
	    					fileName +
				    		'&nbsp;&nbsp;<a href="javascript:;" onclick="file.download(\''+fileId+'\',\''+fileName+'\')">下载</a>' +
							'&nbsp;&nbsp;<a href="javascript:;" onclick="file.preview(\''+fileUrl+'\',\''+fileName+'\')">预览</a>' +
							'&nbsp;&nbsp;<a href="javascript:;" onclick="${idName}_fileDel(this)">删除</a>' +
				    	'</div>';
				    	
			$("#filePicker_${idName}_pre").append($li);
	    }
	    
	    var ${idName}_fileDel = function(o) {
	    	$(o).parents(".file-box").remove();
	    	${idName}_fileValue();
	    }
	    
	    var ${idName}_fileValue = function() {
	    	var val = $("#filePicker_${idName}_pre .file-box").map(function() {
	    		return $(this).attr("data-id")
	    	}).get().join(",");
	    	$("#${idName}_value").val(val);
	    }
    
	    $(document).ready(function(){
	    	if ($("#${idName}_value").val() != "") {
	    		ajax.getSyncData("/admin/sys/file/listByIds", {"ids" : "${value}"}, function(data) {
		    		for(var i = 0; i < data.length; i++) {
		    			${idName}_fileShow(data[i].id, data[i].fileId, data[i].fileName, data[i].fileUrl);
		    		}
		    	});
	    	}
	    	
	    	
	        upload_${idName} = new $WebUpload(fileAccept, 
	            "${idName}", 100, 75, 
	            "", 
	            true,
	            ${size},
	            "", 
	            function(response) {
	            	if ($("#filePicker_${idName}_pre .file-box").length >= ${size}) {
                        return;
            		}
	            	$.ajax({
				        type : "post",
				        cache : false,
				        url : "/admin/sys/file/save",
				        data : JSON.stringify(response.data),
				        contentType : "application/json",
				        success: function(data){
				            if (data.code == '0') {//返回成功处理自行编写
				            	${idName}_fileShow(data.data, response.data.fileId, response.data.fileName, response.data.fileUrl);
			            		${idName}_fileValue();
				            }
				        }
					});
	            }
	        );
	        upload_${idName}.init();
	    });
	    
	</script>
</#macro>

<#macro viewFiles name="" value="">
	<#assign idName=name?replace(".","") />
	<div class="filePicker_btn clearfix">
	    <div id="filePicker_${idName}_pre" class="filePicker_view">
	    </div>
	</div>
	
	<input type="hidden" name="${name}" id="${idName}_value" value="${value}" />
	<script type="text/javascript">
		var ${idName}_fileShow = function(id, fileId, fileName, fileUrl) {
	    	var $li = '<div class="file-box" data-id="'+id+'">' +
	    					fileName +
				    		'&nbsp;&nbsp;<a href="javascript:;" onclick="file.download(\''+fileId+'\',\''+fileName+'\')">下载</a>' +
							'&nbsp;&nbsp;<a href="javascript:;" onclick="file.preview(\''+fileUrl+'\',\''+fileName+'\')">预览</a>' +
				    	'</div>';
				    	
			$("#filePicker_${idName}_pre").append($li);
	    }
	    $(document).ready(function(){
	    	if ($("#${idName}_value").val() != "") {
	    		ajax.getSyncData("/admin/sys/file/listByIds", {"ids" : "${value}"}, function(data) {
		    		for(var i = 0; i < data.length; i++) {
		    			${idName}_fileShow(data[i].id, data[i].fileId, data[i].fileName, data[i].fileUrl);
		    		}
		    	});
	    	}
	    });
	</script>
</#macro>